package com.goods.shop.exam;

import java.util.*;

public class BankQueue {
    public void bankQueue(int[] datas){
        int index=0;
        Queue<Integer> queueA=new LinkedList<>();
        Queue<Integer> queueB=new LinkedList<>();
        int length=datas.length;
        while(index<length){
            if(datas[index]%2==1){
                queueA.offer(datas[index]);
            }else{
                queueB.offer(datas[index]);
            }
            index++;
        }
        int[] result=new int[length];
        index=0;
        while(!queueA.isEmpty()||!queueB.isEmpty()){
           for(int i=0;i<2;i++){
               if(!queueA.isEmpty()){
                   result[index]=queueA.poll();
                   index++;
               }
           }
           if(!queueB.isEmpty()){
               result[index]=queueB.poll();
               index++;
           }
        }
        for(int i=0;i<length;i++) {
            System.out.print(result[i]);
            if(i!=length-1){
                System.out.print(" ");
            }
        }

    }

    public static void main(String[] args) {
        BankQueue service=new BankQueue();
        Scanner scanner1=new Scanner(System.in);
        List<int[]> sourceNums=new ArrayList<>();
        for(int i=0;i<2;i++){
            String line=scanner1.nextLine();
            if(null!=line&&!line.equals("")){
                String[] datas=line.split(" ");
                int[] nums=new int[datas.length-1];
                for(int j=0;j<datas.length-1;j++){
                    nums[j]=Integer.valueOf(datas[j+1]);
                }
                sourceNums.add(nums);
            }

        }
        int count=0;
        for (int[] sourceNum : sourceNums) {
            service.bankQueue(sourceNum);
            if(count!=sourceNums.size()-1)
            {
                System.out.println();
            }
            count++;
        }


    }

}
